package www.openteam.com.presenter.business.other;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.PackTypeInfo;
import www.openteam.com.contract.business.other.SearchPackTypeInfoContract;
import www.openteam.com.model.business.other.SearchPackTypeInfoModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.other.SearchPackTypeFragment;

/**
 * Created by kylin on 2016/11/30.
 */

public class SearchPackTypeInfoPresenter extends BasePresenter<SearchPackTypeFragment>
        implements SearchPackTypeInfoContract.SearchPackTypeInfoPresenter {

    public void queryPackTypeInfo(String name, int pageSize) {

        ((SearchPackTypeInfoModel) getiModelMap().get("searchPT"))
                .queryPackTypeInfo(name, pageSize, new SearchPackTypeInfoModel.SearchPackTypeInfoOnListener() {
                    @Override
                    public void queryPTISuccess(PackTypeInfo packTypeInfo) {
                        getIView().loadPTIData(packTypeInfo);
                    }

                    @Override
                    public void queryPTIFail(Throwable throwable) {
                        getIView().hidePTIData(throwable);
                    }
                });

    }

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new SearchPackTypeInfoModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {

        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("searchPT", models[0]);
        return hashMap;
    }
}
